<template>
    <a-layout>
        <a-layout-header style="background: #fff; padding: 0"/>
        <a-layout-content style="margin: 0 16px">
            <a-breadcrumb style="margin: 16px 0">
                <a-breadcrumb-item>首页</a-breadcrumb-item>
                <a-breadcrumb-item>用户列表</a-breadcrumb-item>
            </a-breadcrumb>
            <div class="toolsbar">
                <div style="float: left;margin-left: 20px;margin-top: 10px;">
                    <a-button @click="addPatient()" type="primary">新建用户</a-button>
                    <a-button :loading="loading" @click="start" style="margin-left: 20px" type="primary">
                        刷新
                    </a-button>
                </div>
                <div class="serach_input">
                    <a-input-group compact>
                        <a-select defaultValue="用户名">
                            <a-select-option value="username">用户名</a-select-option>
                            <!--                    <a-select-option value="username">用户名</a-select-option>-->
                        </a-select>
                        <a-input-search @search="onSearch" defaultValue enterButton style="width: 64%"/>
                    </a-input-group>
                </div>
            </div>

            <div :style="{ padding: '24px', background: '#fff', minHeight: '360px' }">
                <!--                                {{data}}-->

                <a-table
                        :columns="columns"
                        :dataSource="data"
                        :loading="loading"
                        :pagination="pagination"
                        :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
                        bordered
                        rowKey="uid"
                >

                    <template slot="status" slot-scope="text, index" style="text-align: center">
                        <a-tag :color="'green'" v-if="index.status === 1"><span>正常</span></a-tag>
                        <a-tag :color="'red'" v-if="index.status !== 1">封停</a-tag>
                    </template>


                    <template slot="login_time" slot-scope="login_time" style="text-align: center">
                        <span v-if="login_time == '1970/01/01'">-</span>
                        <span v-if="login_time !== '1970/01/01'">{{login_time}}</span>

                    </template>
                    <template slot="login_ip" slot-scope="login_ip" style="text-align: center">
                        <span v-if="login_ip == null">-</span>
                        <span v-if="login_ip !== null">{{login_ip}}</span>

                    </template>
                    <template slot="group_name" slot-scope="group_name" style="text-align: center">
                        <a-tag :color="'red'" v-if="group_name == null">尚未分配权限</a-tag>
                        <a-tag :color="'green'" v-if="group_name !== null">{{group_name}}</a-tag>
                    </template>
                    <template slot="sex" slot-scope="sex" style="text-align: center">
                        <a-tag :color="'red'" v-if="sex == 1">男</a-tag>
                        <a-tag :color="'green'" v-if="sex == 2">女</a-tag>
                    </template>
                    <template slot="d_uid" slot-scope="d_uid" style="text-align: center">
                        {{d_uid}}
                        <!--                        {{Doctordata}}-->
                        <!--                        {{Doctordata[d_uid]["name"]}}-->
                    </template>
                    <template slot="operation" slot-scope="text, index">
                            <span style="margin-right: 5px;">
                              <a @click="showModal(index)">编辑</a>
                            </span>
                        <span>
                              <a @click="delePatient(index)">剔除</a>
                            </span>
                    </template>

                </a-table>
            </div>
        </a-layout-content>
        <a-layout-footer style="text-align: center"></a-layout-footer>
        <a-modal @ok="popok" title="编辑用户信息" v-model="popinfos" width="75%">
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="用户登录账户">
                <a-input disabled="" v-model="edit.login_name"/>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" help="留空则为不修改密码" label="用户登录密码">
                <a-input-password v-model="edit.password"/>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="重复密码">
                <a-input-password v-model="edit.re_password"/>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="用户名字">
                <a-input placeholder="请输入登录名" v-model="edit.name"/>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="用户性别">
                <a-radio-group @change="onChanges" button-style="solid" v-model="edit.sex">
                    <a-radio-button value="1">
                        男
                    </a-radio-button>
                    <a-radio-button value="2">
                        女
                    </a-radio-button>
                </a-radio-group>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="用户联系电话">
                <a-input placeholder="请输入登录名" v-model="edit.mobile"/>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="所属医生">
                <!--                        {{edit.d_uid}}-->
                <a-select @change="handleChange" style="width: 160px" v-model="edit.d_uid">
                    <a-select-option :key="index" :value="item.uid"
                                     v-for="(item,index) in Doctordata">
                        {{item.name}}
                    </a-select-option>
                </a-select>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="选择打卡项目">
                <a-button @click="showPunchinDrawer" type="primary">
                    <a-icon type="plus"/>
                    增加打卡项目
                </a-button>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 18 }" label="用户打开项目">
                <a-table
                        :columns="patient"
                        :dataSource="patientdata"
                        :loading="loading"
                        :pagination="pagination"
                        bordered
                        rowKey="uid"
                >
                    <template slot="interval_type" slot-scope="text, index" style="text-align: center">
                        <a-tag :color="'red'" v-if="index.interval_type === -1"><span>不提醒</span></a-tag>
                        <a-tag :color="'green'" v-if="index.interval_type === 1">每天</a-tag>
                        <a-tag :color="'green'" v-if="index.interval_type === 2">每周</a-tag>
                    </template>
                    <template slot="is_default" slot-scope="text, index" style="text-align: center">
                        <!--                        <a-tag :color="'red'" v-if="index.is_default === -1"><span>不提醒</span></a-tag>-->
                        <a-tag :color="'green'" v-if="index.is_default === 1">默认</a-tag>
                        <a-tag :color="'red'" v-if="index.is_default === 2">非默认</a-tag>
                    </template>
                    <template slot="status" slot-scope="text, index" style="text-align: center">
                        <a-tag :color="'green'" v-if="index.status === 1"><span>正常</span></a-tag>
                        <a-tag :color="'red'" v-if="index.status !== 1">异常</a-tag>
                    </template>
                    <template slot="operation" slot-scope="text, index">
<!--                            <span style="margin-right: 5px;">-->
<!--                              <a @click="showModal(index)">设置默认</a>-->
<!--                            </span>-->
                        <span>
                              <a @click="delObject(index)">剔除</a>
                            </span>
                    </template>

                </a-table>


            </a-form-item>


        </a-modal>
        <a-modal @ok="addok" title="新增用户" v-model="popadd" width="45%">
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="用户登录账户">
                <a-input placeholder="请输入登录名" v-model="add.login_name"/>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" help="" label="用户登录密码">
                <a-input-password placeholder="请输入密码" v-model="add.password"/>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" help="" label="重复登录密码">
                <a-input-password placeholder="请输入重复密码" v-model="add.re_password"/>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="用户名字">
                <a-input placeholder="请输入登录名" v-model="add.name"/>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="用户性别">
                <a-radio-group button-style="solid" default-value="1" v-model="add.sex">
                    <a-radio-button value="1">
                        男
                    </a-radio-button>
                    <a-radio-button value="2">
                        女
                    </a-radio-button>
                </a-radio-group>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="用户联系电话">
                <a-input placeholder="请输入登录名" v-model="add.mobile"/>
            </a-form-item>
            <a-form-item :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" label="所属医生">
                <!--                {{Doctordata}}-->
                <a-select @change="handleChange" style="width: 160px" v-model="add.d_uid">

                    <a-select-option :key="index" :value="item.uid"
                                     v-for="(item,index) in Doctordata">
                        {{item.name}}
                    </a-select-option>
                </a-select>
            </a-form-item>
            <!--            <a-form-item label="职务id" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">-->
            <!--                <a-input v-model="add.group_id" placeholder="请输入登录名"/>-->
            <!--            </a-form-item>-->

        </a-modal>
        <a-drawer
                :closable="false"
                :visible="Punchinvisible"
                @close="onClose"
                style="z-index: 2000"
                title="打卡列表"
                width="720"
        >

            <!--{{selectedPunchhinRowKeys}}-->
            <!--                        {{Doctordata}}-->
            <a-table
                    :columns="patientin"
                    :dataSource="punchindata"
                    :loading="loading"
                    :pagination="pagination"
                    :row-selection="{ selectedPunchhinRowKeys: selectedPunchhinRowKeys, onChange: onSelectPunchhinChange,type:'radio'}"
                    @change="onChange"
                    bordered
                    rowKey="uid"

            >
                <template slot="interval_type" slot-scope="text, index" style="text-align: center">
                    <a-tag :color="'red'" v-if="index.interval_type === -1"><span>不提醒</span></a-tag>
                    <a-tag :color="'green'" v-if="index.interval_type === 1">每天</a-tag>
                    <a-tag :color="'green'" v-if="index.interval_type === 2">每周</a-tag>
                </template>
                <template slot="is_default" slot-scope="text, index" style="text-align: center">
                    <!--                        <a-tag :color="'red'" v-if="index.is_default === -1"><span>不提醒</span></a-tag>-->
                    <a-tag :color="'green'" v-if="index.is_default === 1">默认</a-tag>
                    <a-tag :color="'red'" v-if="index.is_default === 2">非默认</a-tag>
                </template>
                <template slot="status" slot-scope="text, index" style="text-align: center">
                    <a-tag :color="'green'" v-if="index.status === 1"><span>正常</span></a-tag>
                    <a-tag :color="'red'" v-if="index.status !== 1">异常</a-tag>
                </template>
            </a-table>

            <div
                    :style="{
                      position: 'absolute',
                      bottom: 0,
                      width: '100%',
                      borderTop: '1px solid #e8e8e8',
                      padding: '10px 16px',
                      textAlign: 'right',
                      left: 0,
                      background: '#fff',
                      borderRadius: '0 0 4px 4px',
                    }"
            >
                <a-button @click="onClose" style="marginRight: 8px">
                    取消
                </a-button>
                <a-button @click="addObject" type="primary">
                    提交
                </a-button>
            </div>
        </a-drawer>
    </a-layout>

</template>

<script>
    const columns = [
        {
            title: "id",
            dataIndex: "uid",

            scopedSlots: {customRender: "uid"}
        },
        {
            title: "用户名",
            dataIndex: "login_name",

            scopedSlots: {customRender: "login_name"}
        },
        {
            title: "名字",
            dataIndex: "name",

            scopedSlots: {customRender: "name"}
        },

        {
            title: "性别",
            dataIndex: "sex",

            scopedSlots: {customRender: "sex"}
        },
        {
            title: "隶属医生",
            dataIndex: "d_name",

            scopedSlots: {customRender: "d_name"}
        },
        {
            title: "最后登录时间",
            dataIndex: "login_time",

            scopedSlots: {customRender: "login_time"}
        },
        {
            title: "最后登录ip",
            dataIndex: "login_ip",

            scopedSlots: {customRender: "login_ip"}
        },
        // {
        //     title: "状态",
        //     width: "5%",
        //     dataIndex: "status",
        //     scopedSlots: {customRender: "status"}
        // },
        {
            title: '操作',
            width: "12%",
            key: 'operation',
            scopedSlots: {customRender: 'operation'}
        },
    ];
    const patient = [
        {
            title: "id",
            dataIndex: "id",

            scopedSlots: {customRender: "id"}
        },
        {
            title: "标题",
            dataIndex: "title",

            scopedSlots: {customRender: "title"}
        },
        {
            title: "提醒类型",
            dataIndex: "interval_type",

            scopedSlots: {customRender: "interval_type"}
        },

        {
            title: "重复周期",
            dataIndex: "interval_time",

            scopedSlots: {customRender: "interval_time"}
        },
        {
            title: "默认",
            dataIndex: "is_default",

            scopedSlots: {customRender: "is_default"}
        },
        {
            title: "状态",
            dataIndex: "status",

            scopedSlots: {customRender: "status"}
        },

        {
            title: '操作',
            width: "15%",
            key: 'operation',
            scopedSlots: {customRender: 'operation'}
        },
    ];
    const patientin = [
        {
            title: "id",
            dataIndex: "id",

            scopedSlots: {customRender: "id"}
        },
        {
            title: "标题",
            dataIndex: "title",

            scopedSlots: {customRender: "title"}
        },
        {
            title: "提醒类型",
            dataIndex: "interval_type",

            scopedSlots: {customRender: "interval_type"}
        },

        {
            title: "重复周期",
            dataIndex: "interval_time",

            scopedSlots: {customRender: "interval_time"}
        },
        {
            title: "默认",
            dataIndex: "is_default",

            scopedSlots: {customRender: "is_default"}
        },
        {
            title: "状态",
            dataIndex: "status",

            scopedSlots: {customRender: "status"}
        },
    ];
    // const rowSelection = {
    //     onChange: (selectedRowKeys, selectedRows) => {
    //         console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
    //     },
    //     onSelect: (record, selected, selectedRows) => {
    //         console.log(record, selected, selectedRows);
    //     },
    //     onSelectAll: (selected, selectedRows, changeRows) => {
    //         console.log(selected, selectedRows, changeRows);
    //     },
    // };

    import {Modal} from "ant-design-vue";
    import Storage from "../common/storage";
    import moment from "moment";
    // import * as Util from "../common/util";

    export default {
        name: "Dashboard",
        components: {},
        data() {
            return {
                columns,
                patient,
                patientin,
                patientdata: [],
                punchindata: [],
                selectedRowKeys: [],
                selectedPunchhinRowKeys: [],
                selectedPunchhinRow: [],
                data: [],
                pagination: {
                    pageSize: 10
                },
                popinfos: false,
                Punchinvisible: false,
                popadd: false,
                Doctordata: Storage.Doctordata,
                search_text: "",
                loading: false,
                add: {
                    login_name: "",
                    password: "",
                    re_password: "",
                    name: "",
                    sex: "",
                    mobile: "",
                    type: "",
                    group_id: "",
                    d_uid: "",
                    account_group_id: "",
                },
                edit: {
                    uid: "",
                    login_name: "",
                    password: "",
                    re_password: "",
                    name: "",
                    sex: "2",
                    mobile: "",
                    d_uid: "",
                },
                del:{
                    ids:[],
                },
            };
        },
        created() {
            // 获取第一页内容
            this.doSearch(1, this.pagination.pageSize, "");

            this.getpunchin(1, this.pagination.pageSize, "");
        },
        methods: {
            start() {
                this.loading = true;
                this.data = [];
                // ajax request after empty completing
                setTimeout(() => {
                    this.loading = false;
                    this.selectedRowKeys = [];
                }, 1000);
                this.doSearch(1, this.pagination.pageSize);
            },
            onSelectChange(selectedRowKeys) {
                console.log('selectedRowKeys changed: ', selectedRowKeys);
                this.selectedRowKeys = selectedRowKeys;
            },
            onSelectPunchhinChange(selectedRowKeys,selectedRows) {
                this.selectedPunchhinRowKeys = [];
                console.log('selectedRowKeys changed: ', selectedRowKeys);
                console.log('selectedRowKeys changed: ', selectedRows);
                this.selectedPunchhinRowKeys = selectedRowKeys;
                this.selectedPunchhinRow = selectedRows;

                this.add.ids=[];
                this.add.uids=[];
                this.add.ids.push(selectedRows[0].id);
                this.add.uids.push(this.edit.uid);
                console.log('this.add.ids: ', this.add.ids);
                console.log('this.add.uids: ', this.add.uids);

            },
            async onSearch(text) {
                this.data = []
                this.search_text = text;
                this.doSearch(1, this.pagination.pageSize, text);
            },
            handleChange(value) {
                console.log(`selected ${value}`);
            },
            onClose() {
                this.Punchinvisible = false;
            },
            async onChange(pagination) {
                await this.doSearch(
                    this.search_text,
                    pagination.current - 1,
                    pagination.pageSize
                );
            },

            async onChanges(e) {
                console.log(e.target.value);
            },
            showPunchinDrawer() {
                this.Punchinvisible = true;
            },
            showModal(item) {
                console.log(item)
                this.edit.login_name = item.login_name;
                this.edit.password = item.password;
                this.edit.re_password = item.re_password;
                this.edit.name = item.name;
                this.edit.sex = item.sex.toString();
                this.edit.mobile = item.mobile;
                this.edit.uid = item.uid;
                this.edit.d_uid = item.d_uid;
                this.getinfo(item.uid)
                this.popinfos = true;
            },
            addPatient() {
                this.add.login_name = "";
                this.add.password = "";
                this.add.re_password = "";
                this.add.name = "";
                this.add.sex = "1";
                this.add.mobile = "";
                this.add.d_uid = "";
                this.popadd = true;
            },
            async popok() {
                if (this.edit.login_name == "") {
                    Modal.warning({
                        title: "请输入用户名"
                    });
                    this.popinfos = true;
                    return
                }
                if (this.edit.password != this.edit.re_password) {
                    Modal.warning({
                        title: "两次密码不一致"
                    });
                    this.popinfos = true;
                    return
                }
                let now = Date.now();
                let result = await this.$post("/api/admin/customer/update", {
                    uid: Storage.uid,
                    token: Storage.token,
                    edit_uid: this.edit.uid,
                    save_value: {
                        login_name: this.edit.login_name,
                        password: this.edit.password,
                        name: this.edit.name,
                        sex: this.edit.sex,
                        mobile: this.edit.mobile,
                        t: now,
                    },

                });

                if (result.status === true) {
                    this.data = []
                    await this.doSearch(1, this.pagination.pageSize, "");
                    Modal.info({
                        title: "更新成功"
                    });
                }
                this.popinfos = false;
            },
            async addok() {


                if (this.add.login_name == "") {
                    Modal.warning({
                        title: "请输入用户名"
                    });
                    this.popinfos = true;
                    return
                }
                if (this.add.password == "") {
                    Modal.warning({
                        title: "请输入登录密码"
                    });
                    this.popinfos = true;
                    return
                }
                if (this.add.password != this.add.re_password) {
                    Modal.warning({
                        title: "两次密码不一致"
                    });
                    this.popinfos = true;
                    return
                }

                let now = Date.now();
                let result = await this.$post("/api/admin/customer/create", {
                    uid: Storage.uid,
                    token: Storage.token,
                    save_value: {
                        login_name: this.add.login_name,
                        password: this.add.password,
                        name: this.add.name,
                        sex: this.add.sex,
                        mobile: this.add.mobile,
                        d_uid: this.add.d_uid,
                        account_group_id: this.add.account_group_id,
                        t: now,
                    },
                });

                if (result.status === true) {
                    this.data = []
                    await this.doSearch(1, this.pagination.pageSize, "");
                    Modal.info({
                        title: "创建成功"
                    });
                }
                this.popadd = false;
            },
            async doSearch(page, limit, search, rule_group_id, type) {
                this.loading = true;
                this.data = [];
                console.log(Storage.uid)
                console.log(Storage.token)
                let now = Date.now();
                let result = await this.$get("/api/admin/customer/list", {
                    params: {
                        token: Storage.token,
                        uid: Storage.uid,
                        page: page,
                        limit: limit,
                        search: search,
                        rule_group_id: rule_group_id,
                        type: type,
                        t: now,
                    }
                });

                if (result.status === true) {
                    let data = [...this.data];
                    for (let i in result.data.list) {
                        let info = result.data.list[i];
                        let offset = (parseInt(page) - 1) * limit + parseInt(i);
                        // console.log(offset)

                        data[offset] = {
                            uid: info.uid,
                            name: info.name,
                            group_name: info.group_name,
                            login_ip: info.login_ip,
                            login_name: info.login_name,
                            login_time: moment(info.login_time * 1000).format("YYYY/MM/DD"),
                            // login_time: info.login_time,
                            mobile: info.mobile,
                            nike_name: info.nike_name,
                            sex: info.sex,
                            status: info.status,
                            d_uid: info.d_uid,
                            d_name: info.d_name,
                        };
                    }

                    let pagination = {...this.pagination};
                    pagination.total = result.data.total;
                    this.pagination = pagination;
                    this.data = data;
                    this.loading = false;
                }

                this.loading = false;
            },
            async getpunchin(page, limit, search) {
                this.loading = true;
                this.punchindata = [];
                console.log(Storage.uid)
                console.log(Storage.token)
                let now = Date.now();
                let result = await this.$get("/api/admin/signInObject/list", {
                    params: {
                        token: Storage.token,
                        uid: Storage.uid,
                        page: page,
                        limit: limit,
                        search: search,
                        t: now,
                    }
                });

                if (result.status === true) {
                    let data = [...this.punchindata];
                    for (let i in result.data.list) {
                        let info = result.data.list[i];
                        // let offset = (parseInt(page) - 1) * limit + parseInt(i);
                        // console.log(offset)

                        data[i] = {
                            id: info.id,
                            title: info.title,
                            interval_type: info.interval_type,
                            interval_time: info.interval_time,
                            contents: info.contents,
                            status: info.status,
                            is_default: info.is_default,
                        };
                    }

                    let pagination = {...this.pagination};
                    pagination.total = result.data.total;
                    this.pagination = pagination;
                    this.punchindata = data;
                    this.loading = false;
                }

                this.loading = false;
            },
            async getinfo(edit_uid) {
                this.loading = true;
                this.patientdata = [...this.patientdata];
                let now = Date.now();
                let result = await this.$get("/api/admin/accountSignInObject/list", {
                    params: {
                        token: Storage.token,
                        uid: Storage.uid,
                        edit_uid: edit_uid,
                        t: now,
                    }
                });

                if (result.status === true) {
                    let data = [];
                    for (let i in result.data) {
                        let info = result.data[i];
                        // let offset = (parseInt(page) - 1) * limit + parseInt(i);
                        // console.log(offset)

                        data[i] = {
                            contents: info.contents,
                            id: info.id,
                            interval_time: info.interval_time,
                            interval_type: info.interval_type,
                            is_default: info.is_default,
                            rule_content: info.rule_content,
                            sign_in_object_id: info.sign_in_object_id,
                            status: info.status,
                            title: info.title,
                            uid: info.uid,
                        };
                    }

                    // let pagination = {...this.pagination};
                    // pagination.total = result.data.total;
                    // this.pagination = pagination;
                    this.patientdata = data;
                    console.log(this.patientdata)
                    this.loading = false;
                }

                this.loading = false;
            },
            async delePatient(item) {
                var that = this;
                console.log(item);
                Modal.confirm({
                    title: "警告！",
                    content: "是否确认剔除该用户?",

                    onOk: async function () {

                        let result = await that.$post("/api/admin/customer/delete", {

                            uid: Storage.uid,
                            token: Storage.token,
                            edit_uid: item.uid,
                            // notes: this.edit_pop.notes,
                            t: Date.now(),
                            // sign: Crypt.sign([
                            //     Storage.token,
                            //     this.edit_pop.id,
                            //     JSON.stringify(data),
                            //     this.edit_pop.notes,
                            //     this.$config.secret_key,
                            //     now
                            // ])
                        });
                        console.log(result);
                        if (result.status == true) {
                            console.log("准备弹窗！");
                            that.data = []
                            await that.doSearch(1, that.pagination.pageSize, "");

                            Modal.info({
                                title: "剔除成功"
                            });
                        }
                        if (result.status === false) {
                            // that.data = []
                            // await this.doSearch(this.page, "1", "", this.estatedefault, "");
                            Modal.info({
                                title: result.msg
                            });
                        }
                    }

                });


            },
            async addObject() {
                var that = this;
                console.log();

                console.log('ids: ', that.add.ids);
                Modal.confirm({
                    title: "警告！",
                    zIndex: 2000,
                    content: "是否确认增加该项目?",

                    onOk: async function () {

                        let result = await that.$post("/api/admin/accountSignInObject/add", {

                            uid: Storage.uid,
                            token: Storage.token,
                            ids: that.add.ids,
                            uids: that.add.uids,
                            // notes: this.edit_pop.notes,
                            t: Date.now(),
                            // sign: Crypt.sign([
                            //     Storage.token,
                            //     this.edit_pop.id,
                            //     JSON.stringify(data),
                            //     this.edit_pop.notes,
                            //     this.$config.secret_key,
                            //     now
                            // ])
                        });
                        console.log(result);
                        if (result.status == true) {
                            console.log("准备弹窗！");
                            that.data = []
                            await that.doSearch(1, that.pagination.pageSize, "");
                            // that.getDoctorGroup(that.add.d_uid);
                            Modal.info({
                                title: "增加成功",
                                zIndex: 2000,
                            });
                            that.Punchinvisible = false;
                        }
                        if (result.status === false) {
                            that.data = []
                            await this.doSearch(this.page, "1", "", this.estatedefault, "");
                            Modal.info({
                                title: result.msg,
                                zIndex: 2000,
                            });
                            that.Punchinvisible = false;
                        }
                    }

                });


            },
            async delObject(item) {

                var that = this;

                that.del.ids.push(item.id);
                console.log(item);
                Modal.confirm({
                    title: "警告！",
                    content: "是否确认剔除该用户?",

                    onOk: async function () {

                        let result = await that.$post("/api/admin/accountSignInObject/remove", {

                            uid: Storage.uid,
                            token: Storage.token,
                            edit_uid: that.edit.uid,
                            ids: that.del.ids,
                            // notes: this.edit_pop.notes,
                            t: Date.now(),
                            // sign: Crypt.sign([
                            //     Storage.token,
                            //     this.edit_pop.id,
                            //     JSON.stringify(data),
                            //     this.edit_pop.notes,
                            //     this.$config.secret_key,
                            //     now
                            // ])
                        });
                        console.log(result);
                        if (result.status == true) {
                            console.log("准备弹窗！");
                            that.data = []
                            await that.doSearch(1, that.pagination.pageSize, "");

                            Modal.info({
                                title: "剔除成功"
                            });
                        }
                        if (result.status === false) {
                            // that.data = []
                            // await this.doSearch(this.page, "1", "", this.estatedefault, "");
                            Modal.info({
                                title: result.msg
                            });
                        }
                    }

                });


            },
        }
    };
</script>
<style scoped>
    .editable-row-operations a {
        margin-right: 8px;
    }

    #components-layout-demo-custom-trigger .trigger {
        font-size: 18px;
        line-height: 64px;
        padding: 0 24px;
        cursor: pointer;
        transition: color 0.3s;
    }

    #components-layout-demo-custom-trigger .trigger:hover {
        color: #1890ff;
    }

    #components-layout-demo-custom-trigger .logo {
        height: 32px;
        background: rgba(255, 255, 255, 0.2);
        margin: 16px;
    }

    .serach_input {
        width: 25vw;
        float: right;
        margin-top: 10px;
        margin-bottom: 10px;
        text-align: right;
        margin-right: 25px;
    }

    .pages {
        float: right;
        margin-top: 10px;
    }

    .toolsbar {
        display: block;
        width: 100%;
        height: 42px;
        background: #fff
    }
</style>
